//递归调用 封装查询树形方法
export function build_tree(arr: any, id: number) {
    let childs: any = [];
    arr.forEach((v: any) => {
      if (v.pid == id) childs.push(v);
    });
  
    // 对于父节点为0的进行循环，然后查出父节点为上面结果id的节点内容
    childs.forEach((v: any) => {
      v.children = [];
      let buildTree = build_tree(arr, v.id);
      if (buildTree) v.children = buildTree;
    });
    return childs;
  }
  
